<style type="text/css">
	.border-container::after {
		content: "PEDIDOS";
	}
</style>
<div class="container">
	<div class="border-container">
		@if(Session::has('message'))
            <div class="alert alert-success">{{ Session::get('message') }}</div>
        @endif
	
		<table class="table table-striped table-hover table-condensed" id="orderList"></table>
	</div>
	<div class="container-fluid">
		<div class="row">
			<div class="pull-left">{{ HTML::link('order/create', 'Novo Pedido', array('class' => 'btn btn-primary')) }}</div>
			<div class="pull-right">
				<form id="frmFilter" role="form" class="form-inline">
					<div class="form-group">
		                <input type="text" name="orderNumber" class="form-control" placeholder="Nro Pedido">
					</div>
					<div class="form-group">
		                {{ Form::select('customerId', $customers, "", array('class'=>'form-control', 'id' => 'customerId')) }}
					</div>
					<a href="#" id="btnFilter" class="btn btn-default">Filtrar</a>
				</form>
			</div>
		</div>
	</div>
</div>
<script>
	$(document).ready(function() {
		$('#orderList').report({
			source: $.rootUrl + 'order/list',
			maxRows: $.maxRows,
			columns: [
				{ 
					"sTitle": "Nro Pedido", 
	            	"mDataProp": "order_number", 
	            	"bSortable" : false,
	            	"fnRender": function(obj, value) {
						return $('<div/>').append(
							$('<a/>')
								.attr('href', $.rootUrl + 'order/' + obj.aData.id + '/edit')
								.text(value)
						).html();
	            	}
	            },
	            { 
	            	"sTitle": "Ordem", 
	            	"mDataProp": "production_number", 
	            	"bSortable" : false
	            },
	            { 
	            	"sTitle": "Cliente", 
	            	"mDataProp": "customer_name", 
	            	"bSortable" : false
	            },
	            { 
	            	"sTitle": "Entrada", 
	            	"mDataProp": "order_date", 
	            	"bSortable" : false,
	            	"fnRender": function (obj, value) {
	            		return value.split('-').reverse().join('/');
	            	}
	            },
	            { 
	            	"sTitle": "Início da Produção", 
	            	"mDataProp": "production_start_date", 
	            	"bSortable" : false,
	            	"fnRender": function (obj, value) {
	            		return value.split('-').reverse().join('/');
	            	}
	            },
	            { 
	            	"sTitle": "Data de Entrega", 
	            	"mDataProp": "production_end_date", 
	            	"bSortable" : false,
	            	"fnRender": function (obj, value) {
	            		return value.split('-').reverse().join('/');
	            	}
	            }
			]
		});

		$('#customerId').select2({
			width: 200
		});
	});
</script>